package com.xiaotu.spider.weibo.pipeline;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.xiaotu.common.model.StarHotModel;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.common.util.Constants.DataRedisKey;
import com.xiaotu.spider.APipeline;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;

/**
 * @类名 WeiboHotPipeline
 * @日期 2017年4月26日
 * @作者 高海军
 * @功能 微博热搜存储类
 */
@Component("WeiboHotPipeline")
public class WeiboHotPipeline extends APipeline
{
	@Override
	protected void doProcess(ResultItems resultItems, Task task)
	{
		StarHotModel starModel = resultItems
				.get(StarHotModel.class.getName());
		if (starModel == null)
			return;
		Map<String, Object> starMap = new HashMap<String, Object>();
			starMap.put(DataRedisKeyUtils.getHotStarKey(starModel), starModel);
		
		String key = DataRedisKeyUtils
				.getKey(DataRedisKey.Star_NetHot_YYYYMMDD);
		cacheHandler.hMSet(key, starMap);
		cacheHandler.setCacheTimeout(key);
		
	}
	
}
